﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AgileTimeTracker.Domain.Exceptions
{
    public class DomainValidationException : DomainException
    {
        public List<ValidationError> ValidationErrors { get; set; }

        public DomainValidationException(List<ValidationError> errors)
            : base("Validation errors:")
        {
            this.ValidationErrors = errors;
        }

        public override string Message
        {
            get
            {
                var builder = new StringBuilder();
                builder.Append("The following errors were found:\n");
                foreach(var error in this.ValidationErrors)
                {
                    builder.AppendLine(error.Message);
                }

                return builder.ToString();
            }
        }
    }
}
